package vwg.na.vwm.rh.motorsdk.modelo.procesos.daoimpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import vwg.na.vwm.rh.motorsdk.modelo.procesos.dao.IdeCampaignServicioDAO;
import vwg.na.vwm.rh.motorsdk.modelo.procesos.entidadesgrales.IdeCampaign;
import vwg.na.vwm.rh.motorsdk.modelo.procesos.servicios.IdeCampaignServicio;
import vwg.na.vwm.rh.rhmotor.modelo.dao.GenericDAO;

@Repository
public class IdeCampaignServicioDAOImpl extends GenericDAO<IdeCampaignServicio>
	implements IdeCampaignServicioDAO {

    @SuppressWarnings("unchecked")
    @Override
    @Transactional(readOnly = true, propagation = Propagation.REQUIRED)
    public List<IdeCampaign> getAll() {
	return getHibernateTemplate().find("FROM IdeCampaign as i");
    }

    @Override
    public IdeCampaign getCampaignByNombre(String nombre) {
	return (IdeCampaign) getHibernateTemplate().find("FROM IdeCampaign as i "
		+ "WHERE i.nombre = ?", nombre).get(0);
    }


}
